package com.example.backend.service;

import com.example.backend.mapper.CartItemMapper;
import com.example.backend.model.CartItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CartItemService {
    @Autowired
    CartItemMapper mapper;

    @Transactional
    public int insertOne(CartItem item) {
        return mapper.insertOne(item);
    }

    @Transactional
    public int deleteOne(Integer id) {
        return mapper.deleteOne(id);
    }

    @Transactional
    public int updateOne(CartItem item) {
        return mapper.updateOne(item);
    }

    public List<CartItem> findByUser(Integer userid) {
        return mapper.findByUser(userid);
    }
}
